﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>SilverlightFSharp</title>
    <style type="text/css">
        html, body
        {
            height: 100%;
            overflow: auto;
        }
        body
        {
            padding: 0;
            margin: 0;
        }
        .interp
        {
            height: 300;
            text-align: center;
            color: green;
            font-family: arial

        }
    </style>

        <script type="text/javascript" src="Silverlight.js"></script>
        <script type="text/javascript">
         function GetInterpreter(text, divid,  slid)
         {
             //Encode text first
             text = text.replace(",", "##zap##");

            Silverlight.createObject
             (
             "fpinterpreter.xap",  // source
             divid,  // parent element
             slid,  // id for generated object element
             {
             width: "400", height: "300", background: "white",
             version: "2.0.31005.0"
             }, //plugin properties
             {onError: onSilverlightError }, //event handlers
             "initialCode = {code}".replace("{code}", text), //custom properties
             "context"    // context helper for onLoad handler.
            );

        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }
            var errorType = args.ErrorType;

            var iErrorCode = args.ErrorCode;
            var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n";
            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";
            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n"; errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else
                if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }
            throw new Error(errMsg);
        } 
        
        
        
        }
    </script>

</head>
<body>
    Hello, this is a div
    <div id="silverlightControlHost"  class = 'interp' onclick='GetInterpreter(silverlightControlHost.innerText, silverlightControlHost, "interp")'  
    onmouseover='silverlightControlHost.style.textDecoration="underline"'
    onmouseout='silverlightControlHost.style.textDecoration="none"'>
     Def eq7 = eq o [ id, ~0]
    </div>
    and div ended here
</body>
</html>
